from django.core.mail import send_mail
from sending import settings
from django.http import JsonResponse
from rest_framework.views import APIView

class Emaila(APIView):
    def post(self,request):
        subject = "嘿，小傻子"
        message = "this is test email"
        sender = settings.EMAIL_FROM
        receiver =[request.data["receiver"]]
        print(receiver)
        html_message = "<div><h1>%s</h1><h6>一个不折不扣的傻子</h6>" \
                       "<h3>傻子</h3><h3>Sb</h3>" \
                       "<b>你蠢，你萌，你无可救药</b>" \
                       "想不想打我啊****哈哈哈，大傻子 </div>" % "你个大傻子"
        send_mail(subject, message, sender, receiver, html_message=html_message)
        return JsonResponse(status=200,data={"msg":"ok"})